package com.guchenbo.nacos.spring.boot;

import com.alibaba.nacos.api.config.annotation.NacosValue;
import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@NacosPropertySource(dataId = "guchenbo", autoRefreshed = true)
@Slf4j
public class NacosBootApplication implements ApplicationRunner {
    @NacosValue(value = "${config.key}", autoRefreshed = true)
    private String configKey;
    @NacosValue(value = "${override.key}", autoRefreshed = true)
    private String overrideKey;

    public static void main(String[] args) {
        SpringApplication.run(NacosBootApplication.class, args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("configKey: {}, overrideKey: {}", configKey, overrideKey);
    }
}
